<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>服务列表</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<jsp:include page="../include.jsp" />
</head>
<body class="list">
	<div class="bar">
		服务列表&nbsp;总记录数: ${pager.totalCount} (共${pager.pageCount}页)
	</div>
	<div class="body">
		<form id="listForm" action="service.do" method="post">
			<div class="listBar">
				&nbsp;&nbsp;
				<label>查找: </label>
				<select name="searchBy">
					<option value="serviceName"> 
						服务名称
					</option>
					<option value="moduleName"> 
						模块名称
					</option>
				</select>
				<input type="text" name="keyword" value="${pager.keyword}" />
				<input type="button" id="searchButton" class="formButton" value="搜 索" hidefocus />
				&nbsp;&nbsp;
				<label>每页显示: </label>
				<select name="pageSize" id="pageSize">
					<option value="10"<c:if test="${pager.pageSize eq 10}"> selected="selected"</c:if>>
						10
					</option>
					<option value="1"<c:if test="${pager.pageSize eq 1}"> selected="selected"</c:if>>
						1
					</option>
					<option value="20"<c:if test="${pager.pageSize eq 20}"> selected="selected"</c:if>>
						20
					</option>
					<option value="50"<c:if test="${pager.pageSize eq 50}"> selected="selected"</c:if>>
						50
					</option>
					<option value="100"<c:if test="${pager.pageSize eq 100}"> selected="selected"</c:if>>
						100
					</option>
				</select>
			</div>
			<table id="listTable" class="listTable">
				<tr>
					<th class="check">
						<input type="checkbox" class="allCheck"/>
					</th>
					<th>
						<a href="#" class="sort" name="name" hidefocus>服务名称</a>
					</th>
					<th>
						<a href="#" class="sort" name="state" hidefocus>服务状态</a>
					</th>
					<th>
						<a href="#" class="sort" name="mode" hidefocus>服务模式</a>
					</th>
					<th>
						<a href="#" class="sort" name="module" hidefocus>所属模块</a>
					</th>
					<th>
						<a href="#" class="sort" name="listener" hidefocus>服务监听器</a>
					</th>
					<th>
						<span>操作</span>
					</th>
				</tr>
				<c:forEach items="${pager.list}" var="service">
					<tr>
						<td>
							<input type="checkbox" name="ids" value="${service.name}" 
							<c:if test="${fn:contains(service.module,'org.dding.admin')}">disabled="disabled" title="管理服务不能删除"</c:if>/>
						</td>
						<td>
							<span title="${service.name}">${service.name}
							</span>
						</td>
						<td>
							${service.state}
						</td>
						<td>
							${service.mode}
						</td>
						<td>
							<a href="../moduleAction/module.do?keyword=${service.module}&searchBy=moduleName">${service.module}</a>
						</td>
						<td>
						
						</td>
						<td>
							<c:choose>
								<c:when test="${fn:contains(service.module,'org.dding.admin')}">
									[启动]
									[停止]
									[删除]
									[暂停]
								</c:when>
								<c:otherwise>
									<c:choose><c:when test="${service.enableState.start}">
									<a href="operation.do?id=${service.name}&operation=start" title="启动">[启动]</a>
									</c:when><c:otherwise>[启动]</c:otherwise></c:choose>
									<c:choose><c:when test="${service.enableState.stop}">
										<a href="operation.do?id=${service.name}&operation=stop" title="停止">[停止]</a>
									</c:when><c:otherwise>[停止]</c:otherwise></c:choose>
									<c:choose><c:when test="${service.enableState.remove}">
										<a href="operation.do?id=${service.name}&operation=remove" title="删除">[删除]</a>
									</c:when><c:otherwise>[删除]</c:otherwise></c:choose>
									<c:choose><c:when test="${service.enableState.wait}">
										<a href="operation.do?id=${service.name}&operation=wait" title="暂停">[暂停]</a>
									</c:when><c:when test="${!service.enableState.stop}">[暂停]
									</c:when><c:otherwise>
										<a href="operation.do?id=${service.name}&operation=wait" title="恢复">[恢复]</a>
									</c:otherwise></c:choose>
								</c:otherwise>
							</c:choose>
							
						</td>
					</tr>
				</c:forEach>
			</table>
			<c:choose>
				<c:when test="${fn:length(pager.list)!=0}">
					<div class="pagerBar">
						<div class="delete">
							<input type="button" id="deleteButton" class="formButton" url="unloadModule.do" value="卸载服务" disabled="disabled" hidefocus />
						</div>
						<div class="pager">
							<jsp:include page="../common/pager.jsp" />
						</div>
					</div>
				</c:when>
				<c:otherwise>
					<div class="noRecord">没有找到任何记录!</div>
				</c:otherwise>
			</c:choose>
		</form>
	</div>
</body>
</html>